<template>
  <fieldset>
    <legend>购物车</legend>
    <ul>
      <li v-for="(item, i) in cartData" :key="item.id">
        <b>产品名称：{{ item.title }}</b>
        ------
        <b>产品价格：{{ item.price }}</b>
        ------
        <b>产品数量：{{ item.count }}</b>
        ------
        <button @click="delCart(item, i)">-</button>
      </li>
    </ul>
    <h1>总价{{ total }}</h1>
  </fieldset>
</template>
<script setup>
import { cart } from '../store/cart'
import { storeToRefs } from 'pinia'
let shopStore = cart()
let { cartData, total } = storeToRefs(shopStore)
console.log(cartData)

let delCart = (current, i) => {
  shopStore.del(current)
}
</script>
